package com.cai.oamanager.utils;

import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * @version 1.0
 * @author：蔡松坡
 * @date：2021/1/6 12 : 38
 * @package：com.cai.kcsj.utils
 */
public class Uploadpath {
    /**
     * 上传图片
     * @return
     */
    public static String getUploadPath() {
        File path = null;
        try {
            path = new File(ResourceUtils.getURL("classpath:").getPath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if (!path.exists()) path = new File("");
        File upload = new File(path.getAbsolutePath(), "static/img/");
        if (!upload.exists()) upload.mkdirs();
        return upload.getAbsolutePath();
    }
    /**
     * 上传文件
     */
    public static String getUpFilePath(){
        File path = null;
        try {
            path = new File(ResourceUtils.getURL("classpath:").getPath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if (!path.exists()) path = new File("");
        File upload = new File(path.getAbsolutePath(), "static/file/");
        if (!upload.exists()) upload.mkdirs();
        return upload.getAbsolutePath();

    }
}
